var DateFormatterUtil = {
    /**
     * 时间转换，将时间格式转换成 yyyy-MM-dd
     * @param value
     * @param rowObj
     * @param index
     * @returns {*}
     * @constructor
     */
    DateConvertShort: function (value, rowObj, index) {
        if (value == null || value == '') {
            return '';
        }
        var dt;
        if (value instanceof Date) {
            dt = value;
        } else {
            dt = new Date(value);
        }
        var year = dt.getFullYear();
        var month = dt.getMonth() + 1;
        var day = dt.getDate();
        var hour = dt.getHours();
        var min = dt.getMinutes();
        var sefd = dt.getSeconds();
        var dte;
        //补0
        if (month < 10) {
            dte = year.toString() + "-" + "0" + month.toString();
        } else {
            dte = year.toString() + "-" + month.toString();
        }
        if (day < 10) {
            dte = dte + "-" + "0" + day.toString();
        } else {
            dte = dte + "-" + day.toString();
        }
        return dte;
    },
    /**
     * 时间转换，将时间格式转换成 yyyy-MM-dd HH:mm:ss
     * @param value
     * @param rowObj
     * @param index
     * @returns {*}
     * @constructor
     */
    DateConvertLong: function (value, rowObj, index) {
         if (value == null || value == '') {
            return '';
        }
        var dt;
        if (value instanceof Date) {
            dt = value;
        } else {
            dt = new Date(value);
        }
        var year = dt.getFullYear();
        var month = dt.getMonth() + 1;
        var day = dt.getDate();
        var hour = dt.getHours();
        var min = dt.getMinutes();
        var sefd = dt.getSeconds();
        var dte;
        //补0
        if (month < 10) {
            dte = year.toString() + "-" + "0" + month.toString();
        } else {
            dte = year.toString() + "-" + month.toString();
        }
        if (day < 10) {
            dte = dte + "-" + "0" + day.toString();
        } else {
            dte = dte + "-" + day.toString();
        }
        if (hour < 10) {
            dte = dte + " " + "0" + hour.toString();
        } else {
            dte = dte + " " + hour.toString();
        }
        if (min < 10) {
            dte = dte + ":" + "0" + min.toString();
        } else {
            dte = dte + ":" + min.toString();
        }
        if (sefd < 10) {
            dte = dte + ":" + "0" + sefd.toString();
        } else {
            dte = dte + ":" + sefd.toString();
        }
        return dte;
    },
    /**
     * 计算年龄，当前时间-传入时间
     * @param str
     * @returns {*}
     * @constructor
     */
    GetTime2Time: function (str) {
        str=DateFormatterUtil.DateConvertShort(str);
        var r = str.match(/^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2})$/);
        if(r==null){
            return   false;
        }
        var   d=   new   Date(r[1],   r[3]-1,   r[4]);
        if   (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4])
        {
            var   Y   = new  Date().getFullYear();
            return  (Y-r[1]);
        }
    }
}
//比较日期大小
function compareDate(checkStartDate, checkEndDate) {
    var arys1= new Array();
    var arys2= new Array();
    if(checkStartDate != null && checkEndDate != null) {
        arys1=checkStartDate.split('-');
        var sdate=new Date(arys1[0],parseInt(arys1[1]-1),arys1[2]);
        arys2=checkEndDate.split('-');
        var edate=new Date(arys2[0],parseInt(arys2[1]-1),arys2[2]);
        if(sdate > edate) {
            return false;
        }  else {
            return true;
        }
    }
}